import http from '~/utils/axios'
import { LoginParams, UserInfoModel } from './model/demoModel'
import { useRequest } from 'vue-request'
import axios from 'axios'

export enum Api {
  Login = '/statement/customerInterface/login', // 登录
  DeptList = '/statement/customerInterface/listDept', // 查询所有部门
  DeptUserList = '/statement/customerInterface/listDeptUser', // 查询部门所有员工
  Msg = '/statement/customerInterface/sendMessage', // 催办消息接口
}

/**
 * @description: 用户登录
 */
export function login(params: LoginParams) {
  // return axios.post(Api.Login, params)
  return http.request<UserInfoModel>(
      {
        url: Api.Login,
        method: 'POST',
        params,
      },
      {
        isShowMessage: false,
      },
  )
}

/**
 * @description: 查询所有部门
 */
export function getDeptList() {
  return http.request(
      {
        url: Api.DeptList,
        method: 'POST',
      },
      {
        isShowMessage: false,
      },
  )
}

export const testRequest = () => {
  const { data, loading, error } = useRequest({
    url: Api.Login,
    method: 'post',
  })
  return { data, loading, error }
}
